<?php /*a:1:{s:58:"D:\workspace\admin\application\admin\view\noble\level.html";i:1747109556;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title></title>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all"/>
    <style>
        .layui-form-item .layui-input-inline {
            width: 150px;
        }
        .layui-form-label {
            padding: 9px 5px;
            width: auto;
        }
        .layui-table-cell{
            height: auto;
            overflow:visible;
            text-overflow:inherit;
            white-space:normal;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
<!--    <div class="layui-tab layui-tab-brief site-demo-table" lay-filter="demoTitle">-->
<!--        <ul class="layui-tab-title site-demo-title">-->
<!--            <li class="layui-this">贵族等级</li>-->
<!--            <li><a href="/admin/noble/index">贵族记录</a></li>-->
<!--        </ul>-->
<!--    </div>-->
    <div class="layui-card">
        <div class="layui-card-body">
            <table id="demo" lay-filter="test"></table>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: "/layuiadmin/", //静态资源所在路径
    }).extend({
        index: "lib/index", //主入口模块
    }).use(["table", "laydate"], function () {
        $ = layui.jquery, form = layui.form, table = layui.table;
        table.render({
            elem: '#demo',
            id: '#demo',
            url: '/admin/noble/level',
            defaultToolbar: [
                'filter', 'print', {title: '提示', layEvent: 'LAYTABLE_EXCEL', icon: 'layui-icon-table'},
            ],
            page: {
                curr: 1   //默认从第一页开始搜索
            },
            method: "get",
            //where: $("#sbumitForm").serialize(),
            limit: 20,
            limits: [20, 30, 50],
            text: {
                none: '暂无相关数据！'//默认无数据
            },
            response: {
                statusName: 'code',
                statusCode: 0,
                msgName: 'msg',
                countName: 'count',
                dataName: 'list',
            },
            cols: [[ //表头
                {field: 'id', title: '等级序号', width: "9%", align: "center",},
                {field: 'name', title: '等级名称', width: "10%", align: "center",},
                {field: 'props_id', title: '坐骑', width: "11%", align: "center",templet: function (item) {
                        if (!item.props_name) {
                            return '-';
                        }

                        return item.props_name;
                    }
                },
                {field: 'barrage', title: '炫彩弹幕', width: "14%", align: "center",templet: function (item) {
                        if (!item.barrage) {
                            return '-';
                        }

                        var barrage = item.barrage;
                        var html = '';
                        for (var x in barrage) {
                            html += '<div>' + barrage[x].name + ' * ' + barrage[x].amount + '</div>';
                        }

                        return  html;
                    }
                },
                {field: 'trumpet', title: '喇叭', width: "13%", align: "center",templet: function (item) {
                        if (!item.trumpet) {
                            return '-';
                        }

                        return item.trumpet.name + ' * ' + item.trumpet.amount;
                    }
                },
                {field: 'price', title: '开通价格(宝石)', width: "13%", align: "center",},
                {field: 'renew_price', title: '续费价格(宝石)', width: "13%", align: "center",},

                {field: 'gift_discount', title: '礼物折扣', width: "8%", align: "center"},
                {
                    title: '操作', align: "center",templet: function (item) {
                        return '<a class="layui-btn  layui-btn-xs" onclick="edit(' + item['id'] + ')"><i class="layui-icon"></i>编辑</a>';
                    }
                }
            ]],
            done: function (res, curr, count) {
                res.list.forEach(function (item, index) {

                });
            },
        });
    });

    function edit(id) {
        layer.open({
            type: 2,
            title: ["编辑", 'font-size:16px'],
            content: '/admin/noble/level_edit?id=' + id,
            area: ['700px', '665px'],
            //offset: '0px',
        });
    }

    function copywriting(id) {
        layer.open({
            type: 2,
            title: ["文案", 'font-size:16px'],
            content: '/admin/noble/copywriting?noble_id=' + id,
            area: ['800px', '550px'],
            //offset: '0px',
        });
    }

    /*添加*/
    function add() {
        layer.open({
            type: 2,
            title: ["添加", 'font-size:16px'],
            content: '/admin/noble/level_add',
            area: ['750px', '665px'],
            //offset: '0px',
        });
    }

    function del(id) {
        layer.confirm('确认要删除吗？', function (index) {
            $.ajax({
                type: "POST",//请求方式
                url: '/admin/noble/level_del?id=' + id, //请求地址
                dataType: "json",//返回的数据类型
                //请求成功
                success: function (data) {
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1, time: 2000}, function () {
                            window.location.reload();
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2});
                    }
                },
                //请求失败，包含具体的错误信息
                error: function (e) {
                    if (e.responseJSON.msg) {
                        layer.msg(e.responseJSON.msg, {icon: 2});
                    }
                }
            });
        });
    }
</script>
</body>
</html>
